package com.duanyu.mysecurity;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

@SpringBootTest
public class test {

    @Test
    public void testPassword(){
        //创建解析器
        PasswordEncoder encoder = new BCryptPasswordEncoder();

        //密码加密
        String password = encoder.encode("baizhan");
        System.out.println(password);

        //密码校验
        boolean matches = encoder.matches("baizhan",
                "$2a$10$2Ws.gje5pSYmwBMSyAN0IOjSjOBaTFJI4N2YZtwtRtqI92t4be2l2");
        System.out.println(matches);

    }
}
